﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock" x:Class="HCI_Project.MainWindow"
        Title="Endangered Species" WindowState="Maximized">

    <Window.Resources>
        <BitmapImage x:Key="DefaultImage" UriSource="Images/pandaLogo.jpg" />
    </Window.Resources>
    
    <Window.CommandBindings>
        <CommandBinding Command="Save" Executed="SaveCommandBinding_Executed"></CommandBinding>

        <CommandBinding Command="Undo" Executed="UndoCommandBinding_Executed"></CommandBinding>
        <CommandBinding Command="Redo" Executed="RedoCommandBinding_Executed"></CommandBinding>
        <CommandBinding Command="Find" Executed="FilterCommandBinding_Executed"></CommandBinding>

        <CommandBinding Command="SaveAs" Executed="FullScreenCommandBinding_Executed"></CommandBinding>
    </Window.CommandBindings>

    <Window.InputBindings>
        <KeyBinding Key="F" Modifiers="Shift" Command="Find"></KeyBinding>
        <KeyBinding Key="F5" Command="SaveAs"></KeyBinding>
        <KeyBinding Modifiers="Ctrl+Shift" Key="Z" Command="Redo"></KeyBinding>
        
    </Window.InputBindings>

    <Grid>
        <DockPanel LastChildFill="True">
            <Menu IsMainMenu="True" DockPanel.Dock="Top" Foreground="Black" FontWeight="Bold" FontSize="13.333" BorderThickness="0,0,0,2" BorderBrush="#FF41B1E1">
            	<Menu.Background>
                    <SolidColorBrush Color="#ECF0F1">
                    </SolidColorBrush>
            	</Menu.Background>
                <MenuItem Header="File" FontWeight="Normal" Width="75" FontSize="14.667" BorderBrush="#FF41B1E1" BorderThickness="0,0,2,0" >
                    <MenuItem Header="Save"
                                        Command="Save" BorderBrush="White" BorderThickness="0,0,0,1" />
                    <MenuItem Header="Exit"
                                        Command="{Binding OpenCommand}" Click="ExitClick"/>
                </MenuItem>
                <MenuItem Header="Edit" FontWeight="Normal" Width="75" FontSize="14.667" BorderBrush="#FF41B1E1" BorderThickness="0,0,2,0">
                    <MenuItem Header="Undo"
                                        Command="Undo" BorderThickness="0,0,0,1" BorderBrush="White" />
                    <MenuItem Header="Redo"
                                        Command="Redo" BorderThickness="0,0,0,1" BorderBrush="#FF41B1E1" />
                    <MenuItem Header="Edit Species"
                                        Command="{Binding OpenCommand}" Click="EditSpeciesClick" BorderThickness="0,0,0,1" BorderBrush="White" />
                    <MenuItem Header="Edit Types"
                                        Command="{Binding OpenCommand}" Click="EditTypesClick" BorderThickness="0,0,0,1" BorderBrush="White" />
                    <MenuItem Header="Edit Tags" x:Name="editTags" Click="EditTagsClick" 
                                        Command="{Binding OpenCommand}" BorderThickness="0,0,0,1" />
                    <MenuItem Header="Filter"
                                        Command="Find" BorderThickness="0,1,0,0" BorderBrush="#FF41B1E1" InputGestureText="Shift+F" />
                </MenuItem>
                <MenuItem Header="View" FontWeight="Normal" Width="75" FontSize="14.667" BorderBrush="#FF41B1E1" BorderThickness="0,0,2,0">
                    <MenuItem Header="Fullscreen"
                                        Command="SaveAs" BorderThickness="0,0,0,1" BorderBrush="White" InputGestureText="F5"/>
                </MenuItem>
                <MenuItem Header="Add" FontWeight="Normal" Width="75" FontSize="14.667" BorderBrush="#FF41B1E1" BorderThickness="0,0,2,0" >
                    <MenuItem Header="Species"
                                        Command="{Binding OpenCommand}" Click="SpeciesDialogClick" BorderBrush="White" BorderThickness="0,0,0,1" />
                    <MenuItem Header="Types"
                                        Command="{Binding OpenCommand}" Click="TypeWindowClick" BorderBrush="White" BorderThickness="0,0,0,1" />
                    <MenuItem Header="Tags"
                                        Command="{Binding OpenCommand}"  Click="TagDialogClick"/>
                </MenuItem>
                <MenuItem Header="Help" FontWeight="Normal" Width="75" FontSize="14.667" BorderBrush="#FF41B1E1" BorderThickness="0">
                    <MenuItem Header="About"
                                        Command="{Binding OpenCommand}" />
                </MenuItem>
            </Menu>
            <Grid DockPanel.Dock="Bottom">
                <xcad:DockingManager x:Name="dockingManager" Grid.ColumnSpan="3" Background="#ECF0F1" FontSize="13.333" FontWeight="Bold">
                    <xcad:DockingManager.Theme>
                        <xcad:MetroTheme />
                    </xcad:DockingManager.Theme>

                    <xcad:LayoutRoot>
                        <xcad:LayoutPanel Orientation="Horizontal">
                            <xcad:LayoutDocumentPaneGroup>
                                <xcad:LayoutDocumentPane x:Name="Documents">
                                </xcad:LayoutDocumentPane>
                            </xcad:LayoutDocumentPaneGroup>
                        </xcad:LayoutPanel>

                        <xcad:LayoutRoot.LeftSide>
                            <xcad:LayoutAnchorSide>
                                <xcad:LayoutAnchorGroup>
                                    <xcad:LayoutAnchorable Title="Species" CanClose="False" CanFloat="False" CanHide="False" CanAutoHide="True" AutoHideWidth="115">
                                        <DockPanel>
                                            <WrapPanel DockPanel.Dock="Top">
                                                <Border Padding="0,3,0,7">
                                                    <TextBox ToolTip="Search Species by Name." Name="searchBox" Width="115" Height="27" FontSize="16" FontWeight="Normal" TextChanged="SearchTextChanged" BorderThickness="1.75"></TextBox>
                                                </Border>                                                        
                                                </WrapPanel>
                                            <Border DockPanel.Dock="Bottom" BorderThickness="0,1,0,0" BorderBrush="Gray">
                                                <Image Source="Images\trash.png" Width="96" Height="96" PreviewDragOver="ThrashDragOver" Drop="TrashDrop" AllowDrop="True" ToolTip="Drop species to delete them."/>
                                            </Border>
                                                <ScrollViewer>
                                                <StackPanel Orientation="Vertical" CanVerticallyScroll="True" >
                                                    <ListBox Name="speciesList" ItemsSource="{Binding}" BorderBrush="Transparent">
                                                        <ListBox.ItemTemplate>
                                                            <DataTemplate>
                                                                <Border BorderBrush="#FF41B1E1" BorderThickness="0,0,0,1">
                                                                    <StackPanel ToolTip="Drag the item and drop it onto the map." Orientation="Vertical" PreviewMouseLeftButtonDown="SpeciesMouseLeftButtonDown" PreviewMouseMove="SpeciesMouseMove" Uid="{Binding id}">
                                                                        <TextBlock Width="80" Text="{Binding name}" FontWeight="Bold"  />
                                                                        <Image Width="84" Source="{Binding icon,FallbackValue={StaticResource DefaultImage}, TargetNullValue={StaticResource DefaultImage}}" />
                                                                    </StackPanel>
                                                                </Border>
                                                            </DataTemplate>
                                                        </ListBox.ItemTemplate>
                                                    </ListBox>
                                                </StackPanel>
                                            </ScrollViewer>                                           
                                        </DockPanel>
                                    </xcad:LayoutAnchorable>
                                </xcad:LayoutAnchorGroup>
                            </xcad:LayoutAnchorSide>
                        </xcad:LayoutRoot.LeftSide>
                        <xcad:LayoutRoot.RightSide>
                            <xcad:LayoutAnchorSide>
                                <xcad:LayoutAnchorGroup>
                                    <xcad:LayoutAnchorable Title="Maps" CanClose="False" CanHide="False" CanFloat="False" CanAutoHide="True">
                                        <StackPanel Orientation="Vertical">
                                            <ListBox Name="mapList" ItemsSource="{Binding}" BorderBrush="Transparent" Grid.IsSharedSizeScope="True" HorizontalContentAlignment="Stretch">
                                                <ListBox.ItemTemplate>
                                                    <DataTemplate>
                                                        <Button Background="White" BorderBrush="White" Click="MapClick" MouseDoubleClick="MapDoubleClick" Uid="{Binding name}">
                                                            <StackPanel Orientation="Vertical" Margin="0,0,0,50" ToolTip="Click to open this map.">
                                                                <TextBlock Width="90" Text="{Binding name}" FontWeight="Bold"  />
                                                                <Image Width="100" Source="Images\mini_world_map.png" />
                                                            </StackPanel>
                                                        </Button>
                                                    </DataTemplate>
                                                </ListBox.ItemTemplate>
                                            </ListBox>
                                        </StackPanel>
                                    </xcad:LayoutAnchorable>
                                </xcad:LayoutAnchorGroup>
                            </xcad:LayoutAnchorSide>
                        </xcad:LayoutRoot.RightSide>
                    </xcad:LayoutRoot>
                </xcad:DockingManager>
            </Grid>

        </DockPanel>
    </Grid>
</Window>
